package com.xfly.app.ui;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;

import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.net.api.ApiDataRepository;
import com.ptmall.app.net.base.ApiNetResponse;
import com.ptmall.app.view.TitleBarView;
import com.xfly.app.adapter.SjAdapter;
import com.xfly.app.bean.SjBean;
import com.xfly.app.bean.YfBean;

import java.util.ArrayList;
import java.util.List;

public class SjshActivity extends BaseMvpActivity {

    TitleBarView title_bar;
    SjAdapter mSjAdapter;
    List<SjBean> list = new ArrayList<>();
    ApiDataRepository apiDataRepository = ApiDataRepository.getInstance();
    ListView listview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_sjsh);
    }

    @Override
    public void initViews() {
        title_bar = findViewById(R.id.title_bar);
        listview = findViewById(R.id.listview);

        title_bar.setText("升级审核");
    }

    @Override
    public void initEvents() {
        title_bar.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });
        mSjAdapter = new SjAdapter(getContext(),list);
        listview.setAdapter(mSjAdapter);
        mSjAdapter.setClick(new SjAdapter.Click() {
            @Override
            public void Click(int position) {
                Intent intent = new Intent(getContext(),ShDetilActivity.class);
                intent.putExtra("id",list.get(position).id);
                startActivity(intent);
            }

            @Override
            public void Click2(int position) {
                Intent intent = new Intent(getContext(),ShDetilActivity.class);
                intent.putExtra("id",list.get(position).id);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        getlist();
    }

    private void getlist(){
        apiDataRepository.getsjList(null, new ApiNetResponse<List<SjBean>>() {
            @Override
            public void onSuccess(List<SjBean> data) {
                mSjAdapter.pushData(data);
            }
        });
    }
}
